package com.sfac.springboot.springboot.modules.account.controller;

import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class AccountController {

    /**
     * 127.0.0.1/register ---- get
     */
    @GetMapping(value = "/register")
    public String register(ModelMap modelMap) {
        modelMap.addAttribute("template",
                "account/register");
        return "index3";
    }

    /**
     * 127.0.0.1/login ---- get
     */
    @GetMapping(value = "/login")
    public String login(ModelMap modelMap) {
        modelMap.addAttribute("template",
                "account/login");
        return "index3";
    }

    /**
     * 127.0.0.1/account/users ---- get
     */
    @GetMapping(value = "/account/users")
    @RequiresRoles(value={"admin","manager"}, logical= Logical.OR)
    public String usersPage() {
        return "index";
    }

    /**
     * 127.0.0.1/account/roles ---- get
     */
    @GetMapping(value = "/account/roles")
    public String rolesPage() {
        return "index";
    }

    /**
     * 127.0.0.1/account/resources ---- get
     */
    @GetMapping(value = "/account/resources")
    public String resourcesPage() {
        return "index";
    }
}
